﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UE.SharePoint.ImportExport.BLL;

namespace UE.SharePoint.ImportExport
{
    /// <summary>
    /// Represents a status when the sharepoint runtime.
    /// </summary>
    public class WorkStatus : IStatus
    {
        public IList<StatusItem> Messages = new List<StatusItem>();

        /// <summary>
        /// 
        /// </summary>
        public int Count
        {
            get;
            set;
        }

        public int ProcessedNum
        {
            get;
            set;
        }

        public int SucceedNum
        {
            get;
            set;
        }

        public int FailedNum
        {
            get
            {
                return ProcessedNum - SucceedNum;
            }
        }

        private string _logFormat="Row:{0} {1}";
        public string LogFormat
        {
            get { return _logFormat; }
            set { _logFormat = value; }
        }

        public ProcessStatus WriteStatus
        {
            get;
            set;
        }

        public void Log(MessageCategory category, string message)
        {
            Messages.Add(new StatusItem() { MessageCategory = category, Message = message });
        }

        /// <summary>
        /// 
        /// </summary>
        public class StatusItem
        {
            public MessageCategory MessageCategory { get; set; }

            public string Message { get; set; }
        }
    }
}
